﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:controls="clr-namespace:VSTalk.Engine.Controls"
                    xmlns:converter="clr-namespace:VSTalk.Engine.Converters">
    <Style TargetType="{x:Type controls:InterlocutorToolTip}">
        <Style.Resources>
            <converter:VisibleIfNotEmptyConverter x:Key="VisibleIfNotEmptyConverter"/>
        </Style.Resources>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type controls:InterlocutorToolTip}" >
                    <Grid MinWidth="200" MaxWidth="400">
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto"></RowDefinition>
                            <RowDefinition Height="Auto"></RowDefinition>
                            <RowDefinition Height="Auto"></RowDefinition>
                        </Grid.RowDefinitions>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto" />
                            <ColumnDefinition Width="*" />
                            <ColumnDefinition Width="Auto" />
                        </Grid.ColumnDefinitions>
                        <TextBlock Grid.Column="1" Grid.Row="0" 
                                Text="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Summary.Interlocutor.Name}" />
                        <Image Grid.Column="0" Grid.Row="0" Grid.RowSpan="2" Source="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Summary.Photo}" Margin="2"/>
                        <TextBlock Grid.Row="0" Grid.Column="2" Text="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Summary.InterlocutorContext.State}" />
                        <TextBlock Grid.Row="1" Grid.Column="1" VerticalAlignment="Center" 
                                   Grid.ColumnSpan="2" 
                                   Text="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Summary.InterlocutorContext.Bare}" />
                        <ItemsControl Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="3" Width="Auto" 
                                      ItemsSource="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Summary.InterlocutorResources}">
                            <ItemsControl.ItemTemplate>
                                <DataTemplate>
                                    <Border BorderThickness="2,0,0,0" 
                                            BorderBrush="{DynamicResource WhiteBrush}"
                                            Margin="0,2,0,2"
                                            Padding="4,0,0,0">
                                        <Grid>
                                            <Grid.RowDefinitions>
                                                <RowDefinition Height="Auto"/>
                                                <RowDefinition Height="Auto"/>
                                            </Grid.RowDefinitions>
                                            <Grid.ColumnDefinitions>
                                                <ColumnDefinition Width="2*"/>
                                                <ColumnDefinition Width="*"/>
                                            </Grid.ColumnDefinitions>
                                            <TextBlock Grid.Row="0" Grid.Column="0" 
                                                       Text="{Binding ResourceName, Mode=OneWay}" />
                                            <TextBlock Grid.Row="0" Grid.Column="1" 
                                                       HorizontalAlignment="Right" 
                                                       Text="{Binding ResourceShow, Mode=OneWay}" />
                                            <TextBlock Grid.ColumnSpan="2" Grid.Row="1" Grid.Column="0"
                                                   TextWrapping="Wrap"
                                                   Text="{Binding ResourceItem.Status}" 
                                                   Visibility="{Binding ResourceItem.Status, Converter={StaticResource VisibleIfNotEmptyConverter}}"/>
                                        </Grid>
                                    </Border>
                                </DataTemplate>
                            </ItemsControl.ItemTemplate>
                        </ItemsControl>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
</ResourceDictionary>